package com.sws.worktive.util;

import android.content.Context;
import android.content.SharedPreferences;

public class WT_Prefrences {

	private final String TIME_KEY = "time_key";
	private final String POST_KEY = "post_key";
	private final String TOKEN_KEY = "token_key";
	private final String PHONE_NUMBER="phonenumber";

	SharedPreferences sharedPreferences;

	public WT_Prefrences(Context context) {
		sharedPreferences = context.getSharedPreferences("wt_prefrences", Context.MODE_PRIVATE);
	}

	public long getLastPostTime() {
		return sharedPreferences.getLong(TIME_KEY, 0);
	}

	public void setLastPostTime(long lastPostTime) {
		SharedPreferences.Editor editor = sharedPreferences.edit();
		editor.putLong(TIME_KEY, lastPostTime);
		editor.commit();
	}

	public int getPostAvail() {
		return sharedPreferences.getInt(POST_KEY, 0); 
	}

	public void setPostAvail(int postAvail) {
		SharedPreferences.Editor editor = sharedPreferences.edit();
		editor.putInt(POST_KEY, postAvail);
		editor.commit();
	}
	
	public void setToken(String token){
		SharedPreferences.Editor editor=sharedPreferences.edit();
		editor.putString(TOKEN_KEY, token);
		editor.commit();
	}
	
	public String getToken(){
		return sharedPreferences.getString(TOKEN_KEY, "");
	}
	
	public void setPhonenumber(int phonenumber){
		SharedPreferences.Editor editor=sharedPreferences.edit();
		editor.putInt(PHONE_NUMBER, phonenumber);
		editor.commit();
	}
	
	public int getPhonenumber(){
		return sharedPreferences.getInt(PHONE_NUMBER, 0);
	}
	
	

}
